/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.rm.entidades;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * 
 * @author ffbeltran
 */
@Entity
@Table(name = "exp_pieza")
@NamedQueries( {
		@NamedQuery(name = "ExpPieza.findAll", query = "SELECT e FROM ExpPieza e"),
		@NamedQuery(name = "ExpPieza.findById", query = "SELECT e FROM ExpPieza e WHERE e.id = :id"),
		@NamedQuery(name = "ExpPieza.findByJugador", query = "SELECT e FROM ExpPieza e WHERE e.jugador = :jugador"),
		@NamedQuery(name = "ExpPieza.findByPv", query = "SELECT e FROM ExpPieza e WHERE e.pv = :pv"),
		@NamedQuery(name = "ExpPieza.findByNivelEnemigo", query = "SELECT e FROM ExpPieza e WHERE e.nivelEnemigo = :nivelEnemigo"),
		@NamedQuery(name = "ExpPieza.findByIdPartida", query = "SELECT e FROM ExpPieza e WHERE e.idPartida = :idPartida"),
		@NamedQuery(name = "ExpPieza.findByCompartido", query = "SELECT e FROM ExpPieza e WHERE e.compartido = :compartido")})
public class ExpPieza extends ExperienciaBase {
	private static final long serialVersionUID = 1L;

	@Basic(optional = false)
	@Column(name = "valor1")
	private int pv;
	@Basic(optional = false)
	@Column(name = "valor2")
	private int nivelEnemigo;

	public ExpPieza() {
	}

	public ExpPieza(Integer id) {
		super(id);
	}

	public int getPv() {
		return pv;
	}

	public void setPv(int valor1) {
		this.pv = valor1;
	}

	public int getNivelEnemigo() {
		return nivelEnemigo;
	}

	public void setNivelEnemigo(int valor2) {
		this.nivelEnemigo = valor2;
	}

	@Override
	public void actualizaExp() {
		setExp((int) Math.ceil(getPv() + 20 * getNivelEnemigo()));
	}

	@Override
	public String toString() {
		return "org.rm.entidades.ExpPieza[id=" + super.getId() + "]";
	}
}
